/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package grid_search;

import BuildGrid.Search;
import Edge.BuildEdge;
import static Edge.BuildEdge.All_Vertex;
import static Edge.BuildEdge.Vertex_num;
import static Edge.BuildEdge.grids;
import Graph.Parents;
import Graph.Vertex;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author 江南才俊周涛涛
 */
public class Grid_Search {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        //1.地图问题，存在重复的边，存在孤点
        int y=0;
        long sum=0;
        long start = System.currentTimeMillis();
        BuildEdge be = new BuildEdge();
        be.run();
        long end = System.currentTimeMillis();
        System.out.println("初始化时间=" + (end - start) / 1000 + "秒");
        while (true) {
            Scanner sca = new Scanner(System.in);
            y=y+1;
            int x = sca.nextInt();
            if (x == -1) {
                break;
            }
            
            if(x>=1){
                be.update_car(x);
            }

            int query_name = (int) (Math.random() * Vertex_num - 1) + 1;
            System.out.println("query_name=" + query_name);
            List<Parents> p = All_Vertex.get(query_name).getParents();
            try{
            Search sc = new Search(query_name, p.get(0).x, p.get(0).y);
                System.out.println("sumtime"+sc.sumtime);
                sum=sum+sc.sumtime;
                System.out.println("aa"+y+"平均时间"+sum/y);
            }catch(Exception e){
                
            }
        }
    }

}
